<?php
namespace Api\Controller;
use Think\Controller;
class CommentController extends Controller{
	//对软件的评价
		//增加评论
	public function comment(){
		$comment = M("Comment");
		$comment->user_id = $_POST["user_id"];
		$comment->content = trim($_POST["content"]);
		$comment->create_time = time();
		if ($comment->add()){
			$data =["code" =>"success"];
			header("Content-Type: text/json");
			die(json_encode($data));
		}else {
			$data = ["code" => "wrong"];
			header("Content-Type: text/json");
			die(json_encode($data));
		}
	}
	
	public function useComment(){
		$task_id = $_REQUEST['task_id'];
		$task=M("Task");
		$task->c_star=$_REQUEST["star"];
		$task->c_content = $_REQUEST["content"];
		if($task->where("id = $task_id")->save()){
			$data = ["code" => "success"];
			header("Content-Type: text/json");
			die(json_encode($data));
		}else{
			$data = ["code" => "wrong"];
			header("Content-Type: text/json");
			die(json_encode($data));
		}
	}
}